package com.powerunion.datacollection.service;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.powerunion.datacollection.common.SystemException;
import com.powerunion.datacollection.dao.DaoFactory;
import com.powerunion.datacollection.dao.FormDao;
import com.powerunion.datacollection.model.Form;
import com.powerunion.util.log.LogHelper;

public class FormManager {
	private static Logger logger = LogHelper.getInstance().getLogger(
			FormManager.class);
	private FormDao dao = null;

	public FormManager() {  
		super();
		this.dao = (FormDao) DaoFactory.getInstance().getDao(
				FormDao.class);
	}

	public boolean saveMainTblFormCONT(String saveStr) throws Exception  {
		// 参数为空
		if (StringUtils.isEmpty(saveStr)) {
			String[] args = { "saveStr" };
			// 打印错误日志
			StringBuffer msglog = new StringBuffer(
					"empty invoke parameter saveStr NULL ");
			logger.error(msglog.toString());
			throw new SystemException("error.common.parameter.empty", args);
		}
		
		Form form = new Form();
		form.setFsetId("43");
		form.setMainTblFormCONT(saveStr);

		return this.dao.saveMainTblFormCONT(form);
	}
	
	public String getMainTblFormCONT(String fsetId) throws Exception {
		// 参数为空
		if (StringUtils.isEmpty(fsetId)) {
			String[] args = { "fsetId" };
			// 打印错误日志
			StringBuffer msglog = new StringBuffer(
					"empty invoke parameter fsetId NULL ");
			logger.error(msglog.toString());
			throw new SystemException("error.common.parameter.empty", args);
		}
		Form form = new Form();
		form = this.dao.findFormByKey(fsetId);
		String mainTblFormCont = "";
		if(form != null){
			mainTblFormCont = form.getMainTblFormCONT();
		}
		
		return mainTblFormCont;
	}

}
